<?php // no direct access
defined('_JEXEC') or die('Restricted access'); 
$user = JFactory::getUser();
$template = "templates/tpl_automobil/";
//print_r($user->profile_number);exit();
$db = JFactory::getDBO();
$query = "SELECT a.winprice, a.auction_date, p.image, p.model, p.stand, p.katno, p.register_day FROM #__auction a INNER JOIN #__pr_product p ON a.product_id = p.id WHERE a.winid='".$user->profile_number."' ORDER BY a.auction_date";
$db->setQuery($query);
$pros = $db->loadObjectList();

$query = "SELECT DISTINCT p.id FROM #__auction_user au INNER JOIN #__auction a ON au.auction_id = a.id INNER JOIN #__pr_product p ON a.product_id = p.id WHERE au.user_id = ".$user->id." AND a.closed = 1";
$db->setQuery($query);
$proArray = $db->loadResultArray();
$proStr = implode(',', $proArray);

$query = "SELECT a.winprice, a.auction_date, p.image, p.model, p.stand, p.katno, p.register_day, p.id, a.id as auc_id FROM #__auction a INNER JOIN #__pr_product p ON a.product_id = p.id WHERE p.id IN (".$proStr.") ORDER BY a.auction_date DESC";
$db->setQuery($query);
$proBid = $db->loadObjectList();
?>
<link href="<?php echo $template;?>css/reveal.css" rel="stylesheet" type="text/css" />
<script type="text/javascript" src="<?php echo $template;?>js/jquery.reveal.js"></script>
<script language="javascript">
	function delLike(id){
		var del = confirm("Du er ved at slette et produkt fra din liste!");
		if (del == true){
			location.href="index.php?option=com_ecommerce&task=delLike&id="+id;
		}
		else{
			return false;
		}
	}
</script>
<div class="">
	<p>
    	<span class="float_left f28">Profil</span>
        <span class="link-login"><a href="index.php?option=com_user&view=user&task=edit">Edit Profil</a><a href="index.php?option=com_user&view=login&task=logout&Itemid=13" class="m12l"><?php if($user->guest==0) {echo  "Log ud";};?></a></span>
    </p>
    <div class="cb"></div>
	<div class="tt m10b"></div>
</div>
<div class="p5t">
    <div class="box_gude p10l p15t p10b">
    	<div class="box_text_katalog_detail">
            <div class="title_text_katalog">profil <span class="red_color">Info</span></div>
            <div class="p10 mh144">
                <ul class="profil-info">
                    <li><label>E-mail :</label><span><?php echo $user->email;?></span> </li>
                    <li><label>Fima-navn :</label><span><?php echo $user->name;?></span></li>
                    <li><label>Adresse :</label><span><?php echo $user->get('address');?></span></li>
                    <li><label>Postnr.</label><span><?php echo $user->get('code');?></span></li>
                    <li><label>By :</label><span><?php echo $user->get('city');?></span></li>
                    <li><label>Telefon :</label><span><?php echo $user->get('phone');?></span></li>
                    <li><label>CVR-nr :</label><span><?php echo $user->get('cvr');?></span></li>
                    <li><label>Profil nummer :</label><span class="red_color tex_up font18"><?php echo $user->get('profile_number');?></span></li>
                 </ul>
			</div>
      	</div>

        <?php if($user->get('checkout_status') == 0){?>
        <a class="btn m15t" href="index.php?option=com_user&view=register&layout=payment&userid=<?php echo $user->id;?>&active=1&Itemid=13"><img src="templates/tpl_automobil/images/linkauction.jpg"></a>

        <?php }?>
	</div>
    <div class="cb"></div>
    <div class="box_kato">
    	<h3>Mine vundne biler</h3>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" class="boder">
          <tbody><tr>
            <td width="10%" align="center" class="bg_dark_gray"><strong>Image</strong></td>
            <td width="27%" align="center" class="bg_dark_gray"><strong>Mærke/Model </strong></td>
            <td width="7%" align="center" class="bg_dark_gray"><strong>Stand </strong></td>
            <td width="9%" align="center" class="bg_dark_gray"><strong>1.Reg. </strong></td>
            <td width="8%" align="center" class="bg_dark_gray"> <strong>Kat.No</strong></td>
            <td width="14%" align="center" class="bg_dark_gray"> <strong>Auktionsdagen</strong></td>
            <td width="25%" align="center" class="bg_dark_gray"> <strong>Min vudne pris</strong></td>
          </tr>
          <?php foreach($pros as $item){
			?>
          <tr>
            <td class="boder_t boder_l"><a href="<?php echo $link;?>"><?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image."&w=90&h=66&zc=1' title='".$item->model."' alt='".$item->model ."' />";?></a></td>
            <td class="boder_t boder_l tex_up"><?php echo $item->model;?></td>
            <td align="center" class="boder_t boder_l"><?php echo $item->stand;?></td>
            <td align="center" class="boder_t boder_l"><?php echo $item->register_day;?></td>
            <td align="center" class="boder_t boder_l"><?php echo $item->katno;?></td>
            <td align="center" class="boder_t boder_l"><?php echo $item->auction_date;?></td>
            <td align="center" class="boder_t boder_l"><strong><?php echo number_format($item->winprice,0,",","."); ?> DKK</strong></td>
          </tr>

          <?php }?>

        </tbody></table>
    </div>
    <div class="box_kato p15t">
    	<h3>Mine bud</h3>
        <table width="100%" cellspacing="0" cellpadding="0" border="0" class="boder">
          <tbody><tr>
            <td width="10%" align="center" class="bg_dark_gray"><strong>Image</strong></td>
            <td width="27%" align="center" class="bg_dark_gray"><strong>Mærke/Model </strong></td>
            <td width="7%" align="center" class="bg_dark_gray"><strong>Stand </strong></td>
            <td width="9%" align="center" class="bg_dark_gray"><strong>1.Reg. </strong></td>
            <td width="8%" align="center" class="bg_dark_gray"> <strong>Kat.No</strong></td>
            <td width="14%" align="center" class="bg_dark_gray"> <strong>Auktionsdagen</strong></td>
            <td width="25%" align="center" class="bg_dark_gray"> <strong>Mit bud</strong></td>
          </tr>
          <?php foreach($proBid as $item){
			?>
          <tr>
            <td class="boder_t boder_l"><a href="<?php echo $link;?>"><?php echo "<img src='".JURI::root(false)."thumbnail/timthumb.php?src=".JURI::root(false)."components/com_ecommerce/imgupload/".$item->image."&w=90&h=66&zc=1' title='".$item->model."' alt='".$item->model ."' />";?></a></td>
            <td class="boder_t boder_l tex_up"><?php echo $item->model;?></td>
            <td align="center" class="boder_t boder_l"><?php echo $item->stand;?></td>
            <td align="center" class="boder_t boder_l"><?php echo $item->register_day;?></td>
            <td align="center" class="boder_t boder_l"><?php echo $item->katno;?></td>
            <td align="center" class="boder_t boder_l"><?php echo $item->auction_date;?></td>
            <td align="center" class="boder_t boder_l"><a data-reveal-id="myModal-<?php echo $item->id;?>" href="javascript:void(0);" style="font-weight:bold;">Se alle</a></td>
             <div id="myModal-<?php echo $item->id;?>" class="reveal-modal" style="height:465px; top:100px;">
			<iframe src="index.php?option=com_ecommerce&view=detail&layout=mybid&tmpl=component&auc_id=<?php echo $item->auc_id;?>&user_id=<?php echo $user->id;?>" style="width:510px; height:465px;overflow:hidden; border:none;"></iframe>
			<a class="close-reveal-modal">&#215;</a>
		</div>
          </tr>

          <?php }?>

        </tbody></table>
    </div>
</div>